﻿namespace MicroCloud.Systems
{
    /// <summary>
    /// 系统模块DTO实体映射类
    /// </summary>
    public class FileAutoMapperConfiguration : AutoMapperTupleBase
    {
        public FileAutoMapperConfiguration(IServiceProvider serviceProvider)
        {
            this.ServiceProvider = serviceProvider;
        }

        /// <summary>
        /// 获取 服务提供者
        /// </summary>
        protected IServiceProvider ServiceProvider { get; }

        /// <summary>
        /// 获取 文件配置选项
        /// </summary>
        protected FileOption FileOption => ServiceProvider.GetService<IConfiguration>()?.GetFileOption();

        /// <summary>
        /// 创建对象映射
        /// </summary>
        public override void CreateMap()
        {
            CreateMap<FileEntity, FileInfo>();
            CreateMap<FileEntity, FileOutputDto>();
                //.ForMember(dto => dto.RequestPath, opt => opt.MapFrom(entity => $"{FileOption.RequestPath}/{entity.RequestPath}"));
        }
    }
}
